package com.sinven.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sinven.pojo.Comment;
import com.sinven.service.CommentService;
@Controller
public class CommentController {
	@Autowired
	private CommentService commentserice;
	@RequestMapping("pinglun")
	@ResponseBody
	public List<Comment> AddComment(Comment comment){
		System.out.println(comment.getC_content());
		System.out.println(comment.getaId().getA_id());
		System.out.println(comment.getC_fromuserId().getU_id());
		comment.setC_reviewTime(new Date());
		try {
			boolean res=commentserice.addComment(comment);
			if(res) {
				List<Comment> list=commentserice.SelectComentCountBySelf(comment.getaId().getA_id());
				if(list==null) {
					return null;
				}
				return list;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
